#include "cppTutorArray.h"

#include <iostream>

using namespace std;

CcppTutorArray :: CcppTutorArray ()
{
}

CcppTutorArray :: ~CcppTutorArray  ()
{
}

void CcppTutorArray :: m_PointersAndBrackets   ()
{
    int* ip = a;
    int i = 0;

    //the square-bracket syntax works with regular pointers as well
    for(; i < 10; i++)
    {
        ip[i] = i * 10;
        cout << "ip[" << i <<"]\t=\t" << ip[i] << endl;
    }
    cout << endl;
    // without regular array pointers
    for(i = 0; i < 10; i++)
    {
        a[i] = i * 10;
        cout << "a[" << i <<"]\t=\t" << a[i] << endl;
    }
}

#ifdef PASSING_ARRAY_AS_ARGUMENT
void CcppTutorArray :: m_InitializeArray (int *nArray, int nSize)
{
    for (int i = 0; i < nSize; i++)
    {
        nArray [i] = 0;
    }
}

void CcppTutorArray :: m_PrintArray (int nArray [], int nSize)
{
    for (int i = 0; i < nSize; i++)
    {
        cout << "nArray [" << i << "]\t=\t" << nArray [i] << endl;
    }
}
#endif //PASSING_ARRAY_AS_ARGUMENT